home *** CD-ROM | disk | FTP | other *** search
/ CD Fun House 1 / CD Fun House (Wayzata Technology).iso / •The Arcade• / Billiard Parlour •••• / Billiard Parlour.help < prev   
Text File  |  1986-01-08  |  13KB  |  263 lines

  1.  
  2. General Operation
  3.  
  4. Each game has a CUE BALL, except Billiards has two.  A cue ball may be
  5. launched with the mouse.  This is done by placing the mouse near the ball,
  6. pressing, then dragging out a cue line.  The ball is launched upon release
  7. of the mouse button, with speed proportional to the dragged length of the
  8. cue line and direction determined by the line.  No ball other than cue 
  9. ball(s) may be shot; for Billiards the launched ball is always the one 
  10. closest to the initial press-down point of the mouse.
  11.  
  12. Be careful not to shoot too hard - if you 'slam' a nearby object ball, you
  13. may get a 'hop' and not hit the object solidly.  A little practice will
  14. reveal this.  
  15.  
  16. You can arrange balls by holding down the Option key of the keyboard while
  17. you press on, and subsequently drag, a ball.  A menu item 'Arrange Balls'
  18. also performs this function, but must be deselected after arrangement is
  19. complete.  
  20. >>
  21. A hand-cursor results whenever balls may be arranged.  Sunk 
  22. balls deposited near the bottom of the screen can be moved back onto the 
  23. table without recourse to the Option key or menu.
  24.  
  25. ENGLISH is invoked by selecting same on the Options menu, upon which a 
  26. picture of the cue ball face appears to the right of the table. The white 
  27. spot shows where the next shot will strike the cue ball.  Note two things: 
  28. the spot reverts to the default position after each shot, and this default 
  29. lies at the theoretical zero-english height of 7/5 radius.
  30.  
  31. The collision sounds may be turned on or off via the Options menu item
  32. 'Sound'.  Likewise, 'English' has the effect of hiding or bringing
  33. back the English display.  This menu item does not affect the value of
  34. English, which in any case always reverts to zero after any shot.
  35. >>
  36. Scoring may be performed with the 100-carrom scoring rack atop the screen.  
  37. When using the carroms, simply drag carroms to and fro.  The TURN SCORE is 
  38. always reported in the central display just below the carrom rack.  This 
  39. is the number of balls sunk on the previous turn.  For straightforward 
  40. turns the number will be the amount to add into the current player's 
  41. cumulative score.  For scratches, etc. one has to carefully apply whatever 
  42. scoring rules have been agreed upon; in such cases the central display is 
  43. intended as a guide, not an actual score.
  44.  
  45. SCRATCHES are reported (as beeps) when the cue ball is sunk, or in
  46. 8-ball when the 8 is sunk.  For cue ball scratches, the ball is placed
  47. in the right-hand half of the table, at an open location.  As usual the
  48. cue ball may be moved with the Option key or the Options menu entry
  49. 'Arrange Balls'.
  50. >>
  51.  
  52. The Games
  53.  
  54. In BILLIARDS the players alternate between the spotted and unspotted cue
  55. balls.  A score is logged on the central display when the current cue ball
  56. strikes the other two object balls, but only if three rails are hit
  57. by the cue ball before the second object ball is struck.
  58.  
  59. In STRAIGHT POOL the rack is numbered consecutively from 1 through 15, and
  60. sunk balls will be deposited in numerical order.
  61.  
  62. In 8-BALL the rack has a central 8 ball, with a certain pattern of solids
  63. and stripes surrounding, and sunk balls are deposited with solids to the
  64. left and stripes to the right.  There are many different 'favorite' 8-Ball 
  65. rack configurations:  the one chosen for this program guarantees a fairly 
  66. even distribution of stripe/solid placement over a number of breaks. 
  67. >>
  68. In 9-BALL the rack has a central 9 ball, with a certain pattern of balls 1
  69. through 8 surrounding.  Sunk balls are deposited in numerical order.
  70.  
  71. In SNOOKER there are fifteen unmarked balls in the rack, with numbered 
  72. balls 2,3,4,5,6,7 in specific places.  Sunk balls are deposited in two 
  73. groups: numbered and unmarked.
  74.  
  75. In SLOP there are optional rack sizes, and all object balls are unmarked. 
  76.  
  77. The LAG game simply automates the 'lagging' process in which players 
  78. alternately launch a cue ball to see who can come closer to a point or 
  79. rail.  As with other options, players may choose their own lag criteria, 
  80. with the program providing decision aid - in this case a lag line is drawn 
  81. on the screen to indicate final cue ball position.  The lag also has the 
  82. feature that the cue ball may be either dragged or shot while the item is 
  83. checked.  NOTE: This item must be deselected to enable any other game.
  84. >>
  85.  
  86. The Racks
  87.  
  88. The menu items 'Complete Rack' and 'Continuation Rack' provide means for
  89. setting up games.  'Complete Rack' is used to start afresh.  'Continuation
  90. Rack' makes the most sense in Straight Pool variations, by racking all but
  91. the final ball left on the table.  If the number of object balls left is 
  92. less than or greater than one, or if the single ball left is within the 
  93. 15-ball racking triangle the Complete Rack results as a default.
  94. >>
  95. Magnification
  96.  
  97. This is to aid in reading ball numbers and assessing complex positions.
  98.  
  99.   Glass:  A rectangle will follow the mouse movements.  Hold down the
  100.           mouse button to magnify the selected area.  An <Option>-Click
  101.           or a Double-click will cause the magnifying glass to disappear.
  102.   FullScreen:  The table is blown up to greater than full-screen size.  
  103.           Drag the mouse, with the button held down, to scroll the 
  104.           full screen display (as in MacPaint 'ShowPage' mode). An 
  105.           <Option>-Click or a Double-click will cause the screen
  106.           to revert to normal.
  107.  
  108.  
  109. Note:  The startup display (with animated Billiard Parlour scene) may be
  110.        speeded up by holding down the <Option> key.
  111. ~~
  112.  
  113. Origins of Billiard Parlour
  114.  
  115. The project was started as a sharp test of Rascal animation.  We had
  116. worked out fast 'integer calculus' routines for colliding bodies and
  117. performing various rapid graphics functions. These formulas and techniques
  118. coupled with bit-copying of ball images formed the basis for
  119. the reasonably realistic billiard effects.  The final application was thus
  120. written entirely within the Rascal compiler/development system 
  121. environment.
  122.  
  123. The following technical remarks may be of interest to the serious 
  124. programmer.
  125. >>
  126. Perhaps the most salient fact about the billiards algorithms is that no
  127. floating point is used whatsoever.  All calculations are done in 16-bit
  128. integer format.  The reason, of course, is the quest for speed.  Though
  129. floating point variables are easier to work with for dynamical problems,
  130. there is no hope for full pool table dynamics on the Macintosh unless
  131. integer calculations predominate.
  132. >>
  133. The speed of the integer dynamical routines should be evident from a
  134. consideration of what must be done to iterate an entire ensemble of hard
  135. spheres.  Say there are N spheres total in motion on the table.  One must
  136. on every pass of the main iteration loop
  137.  
  138.      1) Update 2N coordinate values.
  139.      2) Update 2N velocity values.
  140.      3) Seek and analyze collisions, requiring N*N/2 checks.
  141.      4) Handle damping and English.
  142.      5) For most games, check for pocket sinking for each of the N balls.
  143.      6) Check for rail bounces for each of N balls.
  144.      
  145. Naturally, some of the above are interrelated - for example collision and
  146. damping are what imply the need for updating velocities.  The fact that
  147. N*N/2 checks are used to seek all collisions is especially cumbersome when
  148. the number N in the ensemble is large.  For a full pool table, this means
  149. 128 checks for collisions are made at each iteration.
  150. >>
  151. An example of trickery intended to optimize speed is that used to check 
  152. for collisions.  The Rascal source has a collision algorithm essentially 
  153. like so:
  154.  
  155.      s := 4*radius*radius;
  156.      loop(,i:=0,++i,i>numballs-1)
  157.      {
  158.        loop(i<numballs-1, j:=i+1, ++j, j>numballs-1)
  159.        {
  160.            dx := x[i] - x[j];
  161.            if dx*dx <= s then
  162.               { dy:= y[i] - y[j];
  163.                 if dx*dx + dy*dy <= s then
  164.                    collide(i,j);
  165.               };
  166.        };
  167.      };
  168. >>
  169.  
  170. The two loops are straightforward, dictating that we are checking for
  171. pair (i,j) collisions where i is not equal to j.  But the primary point is 
  172. that the check dx*dx<s is made first to save time.  Note that two balls 
  173. have collided (that is, penetrate each other) whenever
  174.  
  175.     sqrt(dx*dx + dy*dy) <= 2*radius
  176.     
  177. so collision also implies sqrt(dx*dx)< 2*radius.  The 'sqrt' function can
  178. be dropped, as in the explicit loop above, in the interest of speed.
  179.  
  180. Many such integer calculations were necessary to achieve a certain 
  181. realism.  
  182. >>
  183. Other examples which might interest the programmer are:
  184.  
  185.      1) Each ball has two pictures, which alternate after every multiple
  186.         of pi*radius is moved on the screen.  This gives an impression of
  187.         rolling.
  188.      2) Damping is hard to accomplish with integers.  The primary problem
  189.         is that if we attempt at each iteration something like:        
  190.               vx[i]:= (vx[i]*999)/1000;
  191.               vy[i]:= (vy[i]*999)/1000;              
  192.         then, in general, one of vx or vy will vanish completely before 
  193.         the other, at the tail end of a ball's motion.  This causes 
  194.         swerving at the end of the trajectory, as a ball disappointingly 
  195.         follows one axis or the other.  The solution was to apply the 
  196.         formula only at certain times - not in each iteration - and make 
  197.         sure that total damping is achieved before the final swerve.  This 
  198.         last effect is done by simply stopping the motion after a certain 
  199.         iteration count which depends in turn on the game played and on 
  200.         other conditions.
  201. >>
  202.      3) The difficulty with integer calculus is evident when one considers
  203.         the basic Newtonian iteration:
  204.         
  205.              x[i]:= x[i] + vx[i];
  206.              y[i]:= y[i] + vy[i];
  207.              
  208.         noting that in real-number calculus one would have each velocity
  209.         term multiplied by a small time increment dt.  Because we cannot
  210.         do this with integers (the smallest increment being 1) there is
  211.         the threat that balls will move very far at each iteration.  The
  212.         solution is easy enough: hold all coordinates and velocities as 
  213.         large integers, and divide by a constant only when actually 
  214.         graphing.  Thus in Billiard Parlour the typical coordinates are on 
  215.         the order of 10000 and divisions by 100 are typical at graph time.
  216. >>
  217.      4) The problem of English is a good example of a tough-sounding 
  218.      problem which turns out to be rather trivial to solve.  For English 
  219.      effects at a rail, we add to the reflected velocity the following 
  220.      cross- product expression:
  221.         
  222.               k(omega X velocity)
  223.               
  224.      where omega is a unit vector normal to the plane of the table and 
  225.      indicating angular rotation, while k is the value of (horizontal)
  226.      English.  For vertical English at a rail, we simply add to the normal 
  227.      reflected component Vn the quantity h*Vn where h is now the vertical 
  228.      English.  These rules are not completely exact physically, but it is 
  229.      easy to show that the major qualitative behavior of English at rails 
  230.      is handled correctly with these simple calculations.  For English 
  231.      during ball-ball encounters, the same formula are used, but relegated 
  232.      of course to the center-of-momentum frame, where each ball sees in 
  233.      effect the other ball as a 'rail'.
  234. >>
  235.      5) Billiard Parlour dynamical calculations are not exact, and for the
  236.         sake of speed some 'molecular' effects - in which balls stick 
  237.         together momentarily - have been left in.  These effects occur 
  238.         primarily because of the ambiguity between incoming and outgoing 
  239.         collisions: if two balls mutually penetrate, it is not easy to 
  240.         find out whether they have just had their velocities reflected, or 
  241.         whether now is the time to so reflect.  The ambiguity is 
  242.         especially fierce when many balls are banging around in a clutch.  
  243.         So the application was designed for speed: there is a molecule 
  244.         from time to time, but the molecule does not stay together.  
  245.         Removing all unrealistic effects proves to take too much compute 
  246.         time away from the otherwise pleasing motion.
  247. >>
  248. The serious programmer may also be interested in the various utilities and
  249. methods unrelated to dynamics that went into the project.  The 
  250. magnification feature for reading balls and positions easily is a good 
  251. example of Rascal off-screen port graphics.  The sound of ball clicks is 
  252. achieved by free-form synthesis of 'chirp' waves - i.e. high-frequency, 
  253. brief tone bursts.  The graphics problem presented by the carroms scoring 
  254. rack is surprisingly difficult, and stands as a good example of straight 
  255. quickdraw methods.
  256.  
  257. The key graphics procedures are found on the standard Rascal Jan 1986
  258. release as library entries.  The key library is called __GraphUtils, and
  259. has many things from screen initialization to high-speed sine, cosine, and
  260. square root functions; in general integer techniques for fast graphics.
  261. But other libraries are involved heavily - the interested programmer can
  262. consult the Billiard Parlour source listing in conjunction with the Rascal
  263. User Manual.